package sz.szsmk.citizencard.ui.adapter;

import android.app.AlertDialog;
import android.content.DialogInterface;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;


import sz.szsmk.citizencard.DaggerApplication;
import sz.szsmk.citizencard.R;
import sz.szsmk.citizencard.ui.fragment.BusHomeTransFragment;

/**
 * Copyright (c)2018
 * author: zdh
 * created on: 2018/12/3 16:21
 * description:
 */
public class BusTransAdapter extends RecyclerView.Adapter<BusTransAdapter.BusTransHolder> {
    private BusHomeTransFragment mContext;
    private View view;


    // 天安门坐标
    double mLat1 = 32.039;
    double mLon1 = 118.728;
    // 百度大厦坐标
//    double mLat2 = 40.056858;
//    double mLon2 = 116.308194;

    public BusTransAdapter(BusHomeTransFragment busHomeTransFragment) {
        mContext = busHomeTransFragment;
    }

//    @Override
//    public int getItemViewType(int position) {
//        return R.layout.bus_trans_item;
//    }

    @Override
    public BusTransHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        view = LayoutInflater.from(DaggerApplication.getIns()).inflate(R.layout.bus_trans_item, parent, false);
        return new BusTransHolder(view);
    }

    @Override
    public void onBindViewHolder(BusTransHolder holder, final int position) {
        LinearLayout item = (LinearLayout) holder.itemView.findViewById(R.id.bus_trans_item);
        item.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startRoutePlanTransit();
            }
        });
    }

    public void startRoutePlanTransit() {

    }

    public void showDialog() {
        AlertDialog.Builder builder = new AlertDialog.Builder(DaggerApplication.getIns());
        builder.setMessage("您尚未安装百度地图app或app版本过低，点击确认安装？");
        builder.setTitle("提示");
        builder.setPositiveButton("确认", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });

        builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });

        builder.create().show();

    }


    @Override
    public int getItemCount() {
        return 3;
    }

    public static class BusTransHolder extends RecyclerView.ViewHolder {

        public BusTransHolder(View itemView) {
            super(itemView);

        }
    }

}
